home *** CD-ROM | disk | FTP | other *** search
Text File | 1986-02-25 | 5.8 KB | 170 lines | [TEXT/MACA] |
- \ grdemo - source for Curves, a simple Neon application
- \ 11/04/84 CBD Version 1
- \ 12/21/84 cbd simplified design based on new control classes
- \ 2/18/84 cbd final for release 1.0
- \ 2/19/86 cdn stolen from grDemo for use in floating point demo
-
- decho -echo
- // Ctl
- // CtlWind
- // vScroll
- -> decho
-
- \ Define a class of special vertical scroll bars that
- \ always show digital values for their thumb settings.
- :CLASS VSCtl <Super vScroll
-
- Rect readOut \ visible rect around readout value
- Rect viewReadOut \ view rect for readout number is inset by 4 pixels.
-
- \ update the digital readout of the thumb value
- :M DISPLAY: GetTopX: viewReadOut getBotY: viewReadOut 1- gotoxy
- -curs clear: viewReadOut Get: super 3 .R ;M
-
- \ redraw the readOut rect and display the value inside
- :M DRAW: draw: readout display: self ;M
-
- \ ( val -- ) put new thumb value, draw the readout number
- :M PUT: put: super display: self ;M
-
- \ Build new scroll bar - window must be created 1st
- :M NEW: { left top len wind -- } left top len wind
- New: Super 1 tmode 9 tsize 1 tfont
- \ calculate the coordinates for the readOut rectangles
- left 4- top len + 4+ dup -> len
- left 20 + len 20 + put: readOut draw: readOut
- get: readOut put: viewReadOut 3 3 inset: viewReadOut ;M
-
- ;CLASS
-
- \ now, build three instances of class vSctl. These will be the
- \ three vertical scroll bars for Curves.
- VSctl Vs1 \ Radius
- VSctl Vs2 \ Amplitude
- VSctl Vs3 \ # cycles
- VSctl Vs4 \ # passes
-
- \ assign constants to the window corners, so that we can change
- \ the size of the window and the length of the scroll bars will be
- \ adjusted automatically. These constants relate to the global
- \ coordinates of the Macintosh screen.
- 20 Value gwL
- 60 Value gwT
- 490 Value gwR
- 290 Value gwB
- gwB gwT - 80 - Value vsLen \ len of scroll bars
-
-
- \ Define a subclass of CtlWind containing a drawing pane.
- \ The window will be a RoundDoc, draggable, non-growable.
- :CLASS grWind <Super CtlWind
-
- Rect thePane \ this is where we'll draw the graphics
-
- \ Create a new grWind with rounded corners and title passed by caller
- :M NEW: { taddr tlen -- } gwL gwT gwR gwB put: tempRect
- tempRect tAddr tLen rndWind
- true False New: super ;M \ visible, no close box
-
- \ set defaults appropriate to this class
- :M CLASSINIT: ClassInit: super \ set window class defaults
- false setGrow: self 4 15 320 220 put: thePane
- 2 2 510 320 true setDrag: self ;M
-
- \ handle an update event for this window
- :M DRAW: set: self draw: vs1 draw: vs2 draw: vs3 draw: vs4
- (abs) call BeginUpd (abs) call drawControls
- clear: thePane draw: thePane
- clip: thePane exec: draw \ clip to the pane and draw
- (abs) call EndUpdate
- clip: contRect \ clip back to entire window
- \ cause the scroll bars to draw their readouts
- ;M
-
- \ Put a new draw cfa
- :M SETDRAW: Put: draw ;M
-
- ;CLASS
-
- \ instantiate grWind to create the Curves demo window.
- grWind dwind
-
- scon dTitle "Sines" \ title for dWind
-
- \ set the current GrafPort to fWind so that we can see what's
- \ going on during the compilation.
- set: fwind
-
- \ ( -- p1 p2 p3 p4 ) fetch the drawing parameters from the three scroll bars.
- : @dParms get: vs1 >float
- get: vs2 >float
- get: vs3 >float
- get: vs4 >float ;
-
- \ store new parameter ranges for the three scroll bars.
- : !ranges { max1 max2 max3 max4 -- }
- 1 max1 putRange: vs1 1 max2 putRange: vs2
- 0 max3 putRange: vs3 1 max4 putRange: vs4 ;
-
- \ store starting parameter ranges for the three scroll bars.
- : !vals { max1 max2 max3 max4 -- }
- max1 put: vs1 max2 put: vs2
- max3 put: vs3 max4 put: vs4 ;
-
- \ send the New: message to the window and scroll bars.
- \ this creates them within the Toolbox and displays them.
- : newObjs close: fWind dTitle New: dWind
- 340 40 vsLen dWind new: vs1
- 370 40 vsLen dWind new: vs2
- 400 40 vsLen dWind new: vs3
- 430 40 vsLen dWind new: vs4 ;
-
- scon ab1 "Sines was written in Neon™"
- scon ab2 "by Christopher D. Noé"
- scon ab3 "of Kriya Systems, Inc."
-
- : about 0 tfont 0 tmode 12 tsize
- 8 40 Gotoxy ab1 type
- cr ab2 type cr ab3 type
- initFont ;
-
- \ Define the actions for the various control parts.
- \ each action handler executes a deferred get: on the object whose
- \ address is on the method stack. Since the handler was called from
- \ the Exec: method of a vScroll object, the scroll bar's address
- \ will be on the top of the mstack. The handler then modifies the
- \ value of the thumb, and causes thePane in dWind to be redrawn
- \ be adding its area to the current region.
-
- : doThumb update: dWind ;
- : doPgUp get: myCtl 10 - put: myCtl update: dWind ;
- : doPgDn get: myCtl 10 + put: myCtl update: dWind ;
- : doLnUp get: myCtl 1- put: myCtl update: dWind ;
- : doLnDn get: myCtl 1+ put: myCtl update: dWind ;
-
- : doDraw @dParms Sines ;
-
- 'c doDraw setdraw: dwind
-
- 5 'cfas doLnUp doLnDn doPgUp doPgDn doThumb actions: vs1
- 5 'cfas doLnUp doLnDn doPgUp doPgDn doThumb actions: vs2
- 5 'cfas doLnUp doLnDn doPgUp doPgDn doThumb actions: vs3
- 5 'cfas doLnUp doLnDn doPgUp doPgDn doThumb actions: vs4
-
- \ define the menu for this application. AppleMen is already there.
- 5 Menu Grafmen
-
- \ Define the menu handler words. Each one sets a new handler
- \ for dWind's DRAW method, and then sets appropriate ranges and
- \ titles for the scroll bars, and causes an update event.
-
- \ startup word for the turtle graphics demo
- : fpStart
- 1000 20 gotoxy " fpMenu.txt" getmtxt
- newobjs 100 100 100 100 !ranges
- 25 75 12 1 !vals
- 150. -> x 120. -> y
- -echo -curs
- BEGIN key drop AGAIN \ just loop and listen to events
- ;
-